#! /usr/bin/python

up = 100
a1 = 19

def generateSubSets(n):
    total = 2**(n+1) - 1
    full = []
    for i in range(1, 2**n):
        org = i
	subset = set()
	index = 1
	while(org > 0):
	     if org%2 != 0: subset.add(index)
	     org  /= 2
	     index += 1
	full.append(subset)
    return full

#print generateSubSets(7)
      
full = generateSubSets(7)
qualifier = []
for B in full:
    for C in full:
	if B.isdisjoint(C):  
	   qualifier.append((B, C))

#print qualifier

def exam(ll):
    for (B, C) in qualifier:
	sb = 0
	sc = 0
	for i in B:
	    sb += ll[i]
	for i in C:
	    sc += ll[i]
	if sb == sc: 
	   #print B, C, sb
	   return False
	if len(B) > len(C) and sb < sc: return False
    return True

print exam([0, 19,30,37,38,39,41,44] )
minimal = 100000

def test():
 for a1 in range(1, up):
    for a2 in range(a1+1, up):	
	for a3 in range(a2+1, up):
	    if a1 + a2 <= a3: break
	    for a4 in range(a3+1, up):
		if a1 + a2 <= a4: break
		for a5 in range(a4+1, up):
		    if a1 + a2 <= a5: break
		    for a6 in range(a5+1, up):
			if a1 + a2 <= a6: break
			for a7 in range(a6+1, up):
			    if a1 + a2 <= a7 or a1+a2+a3 <= a6+a7: break
			    ll = [0, a1, a2, a3, a4, a5, a6, a7]
			    #print ll
			    if exam(ll) and sum(ll) < minimal:
			       print ll, sum(ll)
			       return 

test()
